import { Select, Tooltip } from 'antd'
import { queryExpressList } from "@/views/hooks/usePrintExpress"
import { useEffect, useState } from "react"

const ExpressSelect = (props) => {
  const { ...args } = props
	const [expressList, setExpressList] = useState([]);

  useEffect(() => {
		queryExpressList({ type: 0 }).then(res => {
			const d = (res.data || []).map(e => ({ name: e.name, value: e.baseExpressId }));
			setExpressList(d);
		});
  }, [])

  return (
    <Select { ...args }>
      {expressList.map((item, index) => <Option key={index} value={item.value}>
        <Tooltip title={item.name}>{item.name}</Tooltip>
      </Option>)}
    </Select>
  )
}

export default ExpressSelect